
<template>
    <div class="port-page">
        <!-- 顶部按钮 -->
        <div class="but1">
        <router-link to="/home">
         	<el-button type="warning" size="small" class="add btn" style='margin-right: 5px;'  icon="el-icon-menu">首页</el-button>
        </router-link>
        </div>
        <!-- <el-button type="info" class="btn" :loading="searchLoading" @click="search" icon="search">搜索</el-button>
        <el-button type="success" class="btn" @click='componentsShow("add")' icon="edit">添加</el-button>
        <el-button type="danger" class="btn" :disabled="multipleDeleteDisabled" icon="delete" @click="componentsShow('multipleDelete','')">批量删除</el-button> -->

        <!-- 模糊搜索条件 -->
        <div class="search">
        	<el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss" @click='gd'>更多</el-button>
            <el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss1" @click='gd1'>更多</el-button>
            <div class="search-item">
                <el-input placeholder="请输入学生姓名" class="code-search" v-model="keyword" icon="search"></el-input>
            </div>
            <el-button type="primary" class="add btn" style='border-radius:13px ;' :loading="searchLoading" @click="search" icon="el-icon-search"></el-button>
        </div>
        <div class="search1" v-if='aa'>
        	<div class="search-item" >
        		<span>审核状态</span>
        		<el-select v-model="issh" @change="search" class="code-search">
                	<el-option label="所有" value=""></el-option>
                    <el-option label="已审核" value="Y"></el-option>
                    <el-option label="未审核" value="N"></el-option>
                </el-select>
     	    </div>
            <span>电话</span>
        	<div class="search-item">
                <el-input placeholder="请输入电话" class="code-search" v-model="phone" icon="search"></el-input>
            </div>
        </div>


        <!-- 数据表格展示区域 -->
        <el-table
            :data="dataList"
            :v-loading="false"
            element-loading-text="拼命加载中"
            border
            stripe
            size="small"
            align="center"
            class="admin-table"
            :row-class-name="tableRowClassName"
            @select="checkSelect"
            @select-all="checkall">

            <div slot='empty'>
                <img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
                <span style="vertical-align: middle;">暂时还没有内容哦!</span>
            </div>

            <el-table-column
                :prop="v.prop"
                :label="v.label"
                v-for="(v,index) in portTitleList"
                align="center"
                show-overflow-tooltip
                v-if="v.hide != 0"
                :formatter="v.formatter"
                :align="v.align || 'center'"
                :fixed="v.fixed"
                :class-name="v.columnStyle"
                :width="v.width"
                :min-width="v.minWidth"
                :header-align="v.headerAlign || 'center'"
                >
                <template scope="scope">
                    <div slot="reference">
                      <div v-if="scope.column.property == 'zwm'" @click="componentsShow('info',scope)">
                        <img
                        :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl"
                        style="width:20px;vertical-align:middle; float: left;"
                        v-if="scope.column.property == 'zwm'">
                        <span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
                      </div>
                        <span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>

                    </div>
                </template>
            </el-table-column>
            <el-table-column label="不通过原因" v-if="issh=='Y'" align="center">
				<template scope="scope">
					<el-button size="small" type="text" style="color:#1F2D3D">{{scope.row.btgyy}}</el-button>
				</template>
			</el-table-column>

            <el-table-column label="操作" width="170px" v-if="yc"  align="center" fixed="right">
                <template scope="scope">
                    <el-button size="mini" type="success" v-if="scope.row.issh=='Y'" @click="componentsShow('info',scope)">学生详情</el-button>
                    <el-button size="mini" type="success" v-if="scope.row.issh=='N'" @click="componentsShow('tg',scope)">通过</el-button>
                    <el-button size="mini" type="warning" v-if="scope.row.issh=='N'" @click="componentsShow('btg',scope)">不通过</el-button>
                </template>
            </el-table-column>
        </el-table>

        <!-- 分页查询区域 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageindex"
            :page-sizes="pagesizes"
            :page-size="pagesize"
            :layout="layout"
            :total="total"
            class="class-page">
        </el-pagination>
        <!-- 各个组件显示区域 -->
        <BtgComponent v-if="portComponents.btg.toggle" @close="componentsHide" :params="portComponents.btg.params"></BtgComponent>

        <TgComponent v-if="portComponents.tg.toggle" @close="componentsHide" :params="portComponents.tg.params"></TgComponent>
        
        <InfoComponent v-if="portComponents.info.toggle" @close="componentsHide" :params="portComponents.info.params"></InfoComponent>
        <!-- 退费组件 -->
        <freeComponent v-if="portComponents.free.toggle"  @close="componentsHide"  :params="portComponents.free.params"></freeComponent>

        <!-- 动画加载 -->
        <LoadingComponent v-show="isLoading"></LoadingComponent>
    </div>
</template>

<script>

    import qs from 'qs'
    import { mapState } from 'vuex'
    import LoadingComponent from 'components/loading'
    import freeComponent from './free'
    import BtgComponent from './btg'
    import TgComponent from './tg'
    import InfoComponent from 'view/educa/classManage/student/info'
    export default {
        components: { LoadingComponent, BtgComponent,TgComponent,freeComponent,InfoComponent },
        data () {
            return {
            	aa:false,
			    ss:true,
			    ss1:false,
                name: '',
                issh:'',
                yc:true,
                number: '',
                phone: '',
                keyword:'',
                className: '',
                /*组件区域*/
                portComponents: {
                    singleDelete: {
                        type: 'singleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'single',
                            title: '此操作将删除该班级, 是否继续?'
                        }
                    },
                    multipleDelete: {
                        type: 'multipleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'multiple',
                            title: '此操作将删除您选中的班级, 是否继续?'
                        }
                    },
                    free: {
                        type: 'free',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    info: {
                        type: 'info',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                     btg: {
                        type: 'btg',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    tg: {
                        type: 'tg',
                        toggle: false,
                        params: '',
                        data: {}
                    }
                },

                multipleDelNum:'', //获取批量选择的数据
                dataList: [],  //表格数据

                /*
                    prop :  接口参数名
                    label : 接口中文名
                    hide : 是否隐藏这一列
                    align : 这一列对齐顺序 ： left,right,center
                    headerAlign : 这一列表头对齐方式 ： left,right,center
                */
                portTitleList: [
                    {
                        prop:'id',
                        label:'id',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'xh',
                        label:'学号',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'zwm',
                        label:'中文名',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'ywm',
                        label:'英文名',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'bjmc',
                        label:'班级',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'dh',
                        label:'电话',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'100',
                        headerAlign:'center'
                    },
                     {
                        prop:'tfje',
                        label:'退费金额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                     {
                        prop:'issh',
                        label:'是否审核',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'isshmc',
                        label:'是否审核',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'tfsklx',
                        label:'退费收款类型',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'tflx',
                        label:'退费类型',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'tfzh',
                        label:'退费账号',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'100',
                        headerAlign:'center'
                    },
                    {
                        prop:'tfsj',
                        label:'退费时间',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'130',
                        headerAlign:'center'
                    },
                    {
                        prop:'shsj',
                        label:'审核时间',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'130',
                        headerAlign:'center'
                    },
                    {
                        prop:'shrmc',
                        label:'审核人',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'yuer',
                        label:'账户余额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                   
                ],
                portBntList: [//接口按钮列表
//                  {
//                      name:'退费',
//                      type:'free'
//                  }
                ],

                /*动画加载*/
                isLoading: true,//动画加载
                searchLoading: false,//搜索按钮触发按钮动画

                /*模糊搜索条件*/
                inputjkname:'' , //  接口名称,


                /*分页属性设置*/
                layout: 'total, sizes, prev, pager, next, jumper',//组件布局
                pageindex: 1,//当前分页页码
                pagesizes: [12, 24, 36, 72],//显示个数的选择器选项
                pagesize: 12,//每页显示条目数
                total: 0,//总条数
                dropDownData:'', //
            }
        },
        created () {
            //加载页面时调用
            this.$store.dispatch('changeTitle','退费审核');//修改title
            this.$store.dispatch('changeRouterIndex','/cost/student-free');//修改路由
            this.search();//分页获取默认数据
            this.isLoading = true;//动画开始
        },
        mounted () {
            this.isLoading = false;//动画结束
        },
        methods: {
        	gd(){
        		this.aa=true;
        		this.ss=false;
        		this.ss1=true;
        	},
        	gd1(){
        		this.aa=false;
        		this.ss=true;
        		this.ss1=false;
        	},
            tableRowClassName (row, index) {//隔行变色颜色设置
                /*if ( index%4 == 0) {
                    return "table-cell-green";
                }else if( index%4 == 1 ){
                    return "table-cell-yellow";
                }else if( index%4 == 2 ){
                    return "table-cell-red";
                }else{
                    return "table-cell-blue"
                }*/
            },
            tableCellControl (scope) {//表格单元格控制CSS样式
                /*if (scope.row.id == 112 && scope.column.property == "iname") {
                    return {
                        color:"red",
                    }
                }else{
                    return {
                        color:"green",
                    }
                }*/
            },
            shenhe(type,scope){
              scope.row.issh = "Y"
              var logininfo = JSON.parse(localStorage.logininfo);
              var params3 = qs.stringify({
                  id:scope.row.id,
                  issh:scope.row.issh,
                  xxid: logininfo.xxid,
                  yhid: logininfo.id
    						});
      				this.axios.get(this.$store.state.api + 'xstf/updatesh', params3)
              .then(res => {

      				}).catch(res => {})
            },
            search () {//查询搜索触发事件
            	   if(this.issh=='Y'){
            	   	 this.yc=false;
            	   }else{
            	   	this.yc=true;
            	   }

                  var logininfo = JSON.parse(localStorage.logininfo) ;
                this.axios.get(this.$store.state.api + 'xstf/list',{
                    params:{
//                      zwm:this.name,
                        issh:this.issh,
                        dh:this.phone,
                        keyword:this.keyword,
                        xxid:logininfo.xxid,
                        pageindex: this.pageindex,
                        pagesize: this.pagesize
                    }
                }).then( res => {
                    let data = res.data.data;
                    let list = data.list;
                    this.total = data.totalPage;
                    this.dataList = list;
                }).catch( res => {
                })
            },
            handleSizeChange (val) {//每页显示条数触发事件
                this.pagesize = val;
                this.pageindex = 1;
                this.search();
            },
            handleCurrentChange (val) {//分页触发事件
                this.search();
            },
            checkSelect (selection, row) {//点击单选select触发事件
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
            },
            checkall (selection) {//点击全选select触发事件
                // console.log(selection)
                let strID = [];

                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                // console.log(strID.join(","))
                this.multipleDelNum = strID.join(",");
                // console.log(strID)
            },
            /* 组件的弹框  */
            componentsShow (type,data) { //显示组件
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {
                        console.log(this.portComponents[i])

                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;

                        if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id

                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;

                        }else{
                            return;
                        }
                        return;
                    }
                }
            },
            componentsHide (setting) { //关闭组件
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;

                        if (!setting.cancel) {
                           this.search();
                        }
                        return;
                    }
                }
          }
        },
        computed: {
            multipleDeleteDisabled () {
                if (this.multipleDelNum) {
                    return false;
                }else{
                    return true
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    .port-page {
        font-size:12px;

        .btn {
            height: 30px;
            padding:0 10px;
        }
        .code-search {
            max-width: 130px;
            min-width: 100px;
            text-align: center;
            height: 50px;
            /*line-height: 50px;*/
            font-size: 12px;
        }
        .class-page {
            text-align: left;
            margin-top:10px;
        }

        .search-item {
            display: inline-block;
        }

        .narrow {
            width: 80px;
        }
        .but1{
			width: 30%;
			height: 50px;
			float: left;
			line-height: 50px;
		}
		.search{
			width: 70%;
			float: right;
			height: 50px;
			line-height: 50px;
			text-align: right;
		}
		.search1{
			width: 50%;
			height: 50px;
			float: right;
			line-height: 50px;
			margin-right: 0px;
			text-align: right;
		}
		.el-button+.el-button {
    margin-left: 5px;
}

    }
</style>
